<template>
	<view class="shopping_top_bar_main">
		<view class="item_per" v-for="item in ids" :key="item.id" @click="navigateToPage(item.id)"
			:class="{'selected-menu' : item.id === currentSelected}">
			{{item.name}}
		</view>
		<view class="more_type" @click="toClassDetail">
			<view class="more_type_icon">
				<uni-icons type="bars" size="20" color="#fff"></uni-icons>
			</view>
			<view class="more_type_text">
				分类
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'ShoppingTopBar',
		data() {
			return {
				currentSelected: 1,
				ids: [{
						id: 1,
						name: '推荐',
					},
					{
						id: 2,
						name: '户外',
					},
					{
						id: 3,
						name: '生活',
					},
					{
						id: 4,
						name: '出行',
					},
				]
			}
		},
		
		methods: {
			// 点击分类去分类详情页面
			toClassDetail() {			
				uni.navigateTo({
					url: '/pages/tabBar/extUI/shopping_topBar/goodsClassDetail',
					fail(err) {
						uni.showToast({
							icon: 'error',
							title:"请稍后再试...",
							duration:2000
						})
					}
				})
			},
			navigateToPage(id) {
				this.currentSelected = id;
				this.$emit("currentSelectType", id);
			},
		}
	}
</script>

<style scoped>
	.shopping_top_bar_main {
		display: flex;
		flex-direction: row;
		justify-content: space-around;
	}

	.selected-menu {
		color: #fff;
		font-weight: bold;
		font-size: 20px;
	}
	
	.more_type {
		width: 20%;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		/* background-color: #aaaa7f; */
	}

	.more_type_text {
		color: #fff;
		display: flex;
		flex-direction: column;
		justify-content: center;
	}
	
	.more_type_icon{
		margin-left: 40rpx;
	}
	
	.item_per{
		color: #fff;
	}
</style>